package com.bytedance.frameworks.core.thread;

import android.text.TextUtils;
import java.util.concurrent.ThreadFactory;
import java.util.concurrent.atomic.AtomicInteger;

public final class f implements ThreadFactory {
    private static final AtomicInteger a;
    private final ThreadGroup b;
    private final AtomicInteger c;
    private final String d;
    private final TTPriority$Priority e;

    static {
        a = new AtomicInteger(1);
    }

    f(TTPriority$Priority arg3, String arg4) {

        this.c = new AtomicInteger(1);
        this.e = arg3;
        SecurityManager v0 = System.getSecurityManager();
        ThreadGroup v0_1 = v0 != null ? v0.getThreadGroup() : Thread.currentThread().getThreadGroup();
        this.b = v0_1;
        this.d = TextUtils.isEmpty(((CharSequence)arg4)) ? "ttdefault-" + f.a.getAndIncrement() + "-thread-" : arg4 + f.a.getAndIncrement() + "-thread-";
    }

    public final Thread newThread(Runnable arg8) {
        int v6 = 5;
        Thread v0 = new Thread(this.b, arg8, this.d + this.c.getAndIncrement(), 0);
        if(v0.isDaemon()) {
            v0.setDaemon(false);
        }

        if(this.e != null && this.e.getValue() == TTPriority$Priority.LOW.getValue()) {
            v0.setPriority(1);
        }
        else if(v0.getPriority() != v6) {
            v0.setPriority(3);
        }
        else {
            v0.setPriority(v6);
        }

        return v0;
    }
}

